/**
 * Created by ${PRODUCT_NAME}.
 * User: skylerparr
 * Date: 12/26/10
 * Time: 12:47 PM
 * To change this template use File | Settings | File Templates.
 */
package com.thoughtorigin.loader.mock {
import flash.display.Loader;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.events.SecurityErrorEvent;
import flash.utils.Dictionary;

public class MockLoaderInfo extends EventDispatcher {

    public var _listeners: Dictionary = new Dictionary(true);
    private var _loader: Loader = new Loader();

    public function MockLoaderInfo() {
    }

    public function simulateProgress(bytesLoaded: Number, bytesTotal: Number): void {
        dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS, false, false, bytesLoaded, bytesTotal));
    }

    public function simulateComplete(): void {
        dispatchEvent(new Event(Event.COMPLETE))
    }

    public function simulateSecurityError(): void {
        dispatchEvent(new SecurityErrorEvent(SecurityErrorEvent.SECURITY_ERROR))
    }

    public function simulateNetworkError(): void {
        dispatchEvent(new IOErrorEvent(IOErrorEvent.NETWORK_ERROR))
    }

    public function simulateIOError(): void {
        dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR))
    }

    override public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void {
        delete _listeners[type];
        super.removeEventListener(type, listener, useCapture);
    }

    override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void {
        _listeners[type] = listener;
        super.addEventListener(type, listener, useCapture, priority, useWeakReference);
    }

    public function get loader():Loader {
        return _loader;
    }

    public function set loader(value:Loader):void {
        _loader = value;
    }
}
}
